﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.ComponentModel;

namespace PacketBuilder
{
    /// <summary>
    /// Interaction logic for ConsolePanel.xaml
    /// </summary>
    public partial class ConsolePanel : UserControl, INotifyPropertyChanged
    {
        private string consoleText;
        public string ConsoleText
        {
            get { return consoleText; }
            set
            {
                consoleText = value;
                OnPropertyChanged("consoleText");
            }
        }

        public ConsolePanel()
        {
            InitializeComponent();
        }

        private void ClearButton_Click(object sender, RoutedEventArgs e)
        {
            ConsoleText = string.Empty;
        }

        private void SendButton_Click(object sender, RoutedEventArgs e)
        {
            string runToolString = MainWindow.GetOptionsString();
            ConsoleText += "=>" + runToolString + "\n";
            var result = MainWindow.RunCmd(MainWindow.stringCommandToolName, runToolString);
            if (string.Empty != result)
            {
                ConsoleText += "=>" + result + "\n";
            }
        }

        #region Implementation of INotifyPropertyChanged

        public event PropertyChangedEventHandler PropertyChanged;
        public void OnPropertyChanged(string propertyName)
        {
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
        }
        #endregion
    }
}
